package com.py.pythink.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.py.pythink.bo.ContentDto;
import com.py.pythink.bo.UserInfo;
import com.py.pythink.bo.UserSendBo;
import com.py.pythink.bo.UserSendDetailBo;
import com.py.pythink.entity.UserCommen;
import com.py.pythink.entity.UserSend;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserSendDao extends BaseMapper<UserSend> {
    //1.新增发帖
    @Insert("insert into t_usersend(uid,info,type,ctime,flag,nickname,count) values(#{uid},#{info},#{type},now(),1,#{nickname},0)")
    int insertt(UserSend bo);

    //2.查询我的发帖
    @Select("select * from t_usersend where uid = #{uid} order by ctime desc")
    List<UserSendDetailBo> selectByUid(int uid);//从请求消息里面获得

    //查询我的发帖量
    @Select("select count(*) from t_usersend where uid=#{uid}")
    int number(int uid); //前端获得id

    //3.删除我的帖子
    @Delete("delete from t_usersend where uid = #{uid} and id=#{id}")
    int delete(@Param("uid") int uid,@Param("id") int id);


    //4.查看发帖子本人的基本信息(发帖量 和 性别 名称）
    @Select("select ud.nickname,ud.sex,us.ctime,us.count from t_usersend us inner join t_userdetail ud on us.uid=ud.uid where us.id=#{id}")
    UserInfo usersendDetail(int id);


    //5.根据ID获得帖子的信息
    @Select("select * from t_usersend where id=#{id}")
    UserSend selectById(int id);

    //6.修改帖子的点赞数
    @Update("update t_usersend set count=#{count} where id=#{fuid}")
    int updateCount(int count ,int fuid);

    //根据发帖人得到他发过的所有帖子
    @Select("select * from t_usersend where uid=#{uid}")
    List<UserSend> sendnumber(int uid); //前端获得id

    List<UserSend> person();

    //最终实现单层盖楼
    List<UserSend> getHouse();





}
